// ignore_for_file: deprecated_member_use

import 'package:flutter/material.dart';
import 'package:getx/custom/customappbar.dart';
// ignore: import_of_legacy_library_into_null_safe
import 'package:get/get.dart';
import 'package:getx/model/bottomsheet.dart';

// ignore: must_be_immutable
class BottomSheetGetX extends StatefulWidget {
  String name;
  BottomSheetGetX({Key? key, required this.name}) : super(key: key);
  @override
  _BottomSheetGetXState createState() => _BottomSheetGetXState();
}

class _BottomSheetGetXState extends State<BottomSheetGetX> {
  void _snackbar() async {
    Get.bottomSheet(
      Container(
        width: double.infinity,
        height: 500,
        color: Colors.white,
        child: Wrap(
          children: BottomSheets.map(
            (e) => ListTile(
              leading: e.icon,
              title: Text(e.name),
              onTap: () {
                Get.back(result: e.id); // 关闭弹窗
              },
            ),
          ).toList(),
        ),
      ),
      enableDrag: false,
      isDismissible: false,
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: CustomAppbar(widget.name, Theme.of(context).primaryColor),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            RaisedButton(
              onPressed: _snackbar,
              child: Text(
                widget.name,
                style: const TextStyle(
                  fontSize: 20,
                  color: Colors.white,
                ),
              ),
            )
          ],
        ),
      ),
    );
  }
}
